package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppEnterprisePolicySubsidiesRecordService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppEnterprisePolicySubsidiesRecordCreateValidate;
import com.mdd.admin.validate.yylq.TAppEnterprisePolicySubsidiesRecordSearchValidate;
import com.mdd.admin.validate.yylq.TAppEnterprisePolicySubsidiesRecordUpdateValidate;
import com.mdd.admin.vo.yylq.TAppEnterprisePolicySubsidiesRecordDetailVo;
import com.mdd.admin.vo.yylq.TAppEnterprisePolicySubsidiesRecordListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/appEnterprisePolicySubsidiesRecord")
@Api(tags = "羊羊领企---企业政策补贴申请记录管理")
public class TAppEnterprisePolicySubsidiesRecordController {

    @Resource
    ITAppEnterprisePolicySubsidiesRecordService iTAppEnterprisePolicySubsidiesRecordService;

    @GetMapping("/list")
    @ApiOperation(value="企业政策补贴申请记录列表")
    public AjaxResult<PageResult<TAppEnterprisePolicySubsidiesRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                                                    @Validated TAppEnterprisePolicySubsidiesRecordSearchValidate searchValidate) {
        PageResult<TAppEnterprisePolicySubsidiesRecordListedVo> list = iTAppEnterprisePolicySubsidiesRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="企业政策补贴申请记录详情")
    public AjaxResult<TAppEnterprisePolicySubsidiesRecordDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppEnterprisePolicySubsidiesRecordDetailVo detail = iTAppEnterprisePolicySubsidiesRecordService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "企业政策补贴申请记录新增")
    @PostMapping("/add")
    @ApiOperation(value="企业政策补贴申请记录新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppEnterprisePolicySubsidiesRecordCreateValidate createValidate) {
        iTAppEnterprisePolicySubsidiesRecordService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业政策补贴申请记录编辑")
    @PostMapping("/edit")
    @ApiOperation(value="企业政策补贴申请记录编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppEnterprisePolicySubsidiesRecordUpdateValidate updateValidate) {
        iTAppEnterprisePolicySubsidiesRecordService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业政策补贴申请记录删除")
    @PostMapping("/del")
    @ApiOperation(value="企业政策补贴申请记录删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppEnterprisePolicySubsidiesRecordService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
